home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_26 / phasor.asm < prev    next >
Assembly Source File  |  1995-01-01  |  3KB  |  58 lines

  1. code_seg        segment
  2.         assume  cs:code_seg
  3.         org     100h
  4.         jmp     start
  5. ;----------------------------------
  6. ;B/C Software                        ;Author
  7. ;520 North Stateline Rd
  8. ;Sharon, Pa 16146
  9. ;----------------------------------
  10. message1 db     'press Esc to Quit',0dh,0ah,'$'       ;Esc to end phasor
  11. message2 db     'press any other key to play$'        ;or to go again
  12. ;----------------------------------
  13. start   proc    near
  14.         mov     ah,9                 ;DOS function number to print string
  15.         mov     dx,offset message1   ;the message
  16.         int     21h                  ;DOS interrupt
  17.         mov     ah,9                 ;DOS function number to print string
  18.         mov     dx,offset message2   ;the message
  19.         int     21h                  ;DOS interrupt
  20. begin:  mov     ah,0                 ;BIOS function wait for key press
  21.         int     16h                  ;BIOS interrupt
  22.         cmp     ah,1                 ;Esc scan code 
  23.         jz      done                 ;do we stop ?
  24.         call    phasor               ;no call phasor sound
  25.         jmp     begin                ;go see if we do it again
  26. done:   mov     ax,4c00h             ;no exit back to DOS
  27.         int     21h                  ;DOS interrupt
  28. start   endp
  29. ;-------------------------------------------
  30. phasor  proc    near  
  31.         cli                          ;no interrupts
  32.         mov     dx,1800              ;repeat count
  33.         mov     bx,1                 ;start the sound frequency high
  34.         mov     al,10110110xb        ;the magic number
  35.         out     43h,al               ;send it to the port
  36. backx:  mov     ax,bx                ;place our starting frequency in (ax)
  37.         out     42h,al               ;send LSB first
  38.         mov     al,ah                ;place MSB in (al)
  39.         out     42h,al               ;send it next
  40.         in      al,61h               ;must turn speaker on
  41.         or      al,00000011xb        ;with this number
  42.         out     61h,al               ;send it
  43.         inc     bx                   ;lower the frequency
  44.         mov     cx,60               ;adjusted for best sound (for 8mhz clock)
  45. loopx:  loop    loopx                ;delay loop so we can here sound
  46.         dec     dx                   ;decrement repeat count
  47.         cmp     dx,0                 ;is repeat count = to 0
  48.         jnz     backx                ;if not do again
  49.         in      al,61h               ;if = 0 turn speaker off
  50.         and     al,11111100xb        ;number turns speaker off
  51.         out     61h,al               ;send it
  52.         sti                          ;allow interrupts
  53.         ret                          ;go see if user wants to do again
  54. phasor  endp
  55. ;----------------------------------
  56. code_seg        ends
  57.  
  58.